import { provinces } from "./provinces.js"
import { getMonthList } from "@/static/js/public.js"
import { formatTime } from '@/utils/utils.js'

export default {
  data() {
    return {
      selected: [],
      startDate: '',
      provinces: provinces,
      provincesIndex: 0,
      todayDate: '',
      todayMonth: '',

      dataList: [],
      ssjg: "111000000",

      changeMonth: ''
    }
  },
  onReady() { },


  onLoad(e) {
    //获取当前时间
    const date = new Date()
    this.todayMonth = formatTime(date, 'Y-M')
    this.changeMonth = formatTime(date, 'M')
    this.getList()
  },

  onUnload() {

  },
  methods: {
    getList() {
      let params = {
        ssjg: this.ssjg,
        bssj: this.todayMonth
      }
      getMonthList(params).then(res => {
        let obj = JSON.parse(res)
        console.log(obj);
        this.dataList = obj.json.list
      })
    },

    startTime(date) {
      return formatTime(date, 'D')
    },

    endTime(date) {
      return formatTime(date, 'D')
    },

    startMonth(date) {
      return formatTime(date, 'M')
    },

    endMonth(date) {
      return formatTime(date, 'M')
    },

    firstDay(date) {
      return formatTime(date, 'D')
    },

    lastDay(date) {
      return formatTime(date, 'D')
    },

    dateChange(e) {
      console.log(e)
    },
    monthSwitch(e) {
      console.log(e)
      this.changeMonth = e.month
      this.todayMonth = e.year + "-" + e.month
      this.getList()
    },

    //选择办税地点
    provincesChange(e) {
      this.provincesIndex = e.detail.value
      this.ssjg = this.provinces[e.detail.value].unitcode
      this.getList()
    }
  }
}